package day16.FanSe.FS03;

import java.lang.reflect.Field;

public class Text2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException {
//        method1();
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
        Field field = aClass.getDeclaredField("money");
        field.setAccessible(true);
       Student student = (Student) aClass.newInstance();
        Object o = field.get(student);
        System.out.println(o);
    }

    private static void method1() throws ClassNotFoundException, NoSuchFieldException, InstantiationException, IllegalAccessException {
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
        Field field = aClass.getField("name");
        Student student = (Student) aClass.newInstance();
        field.set(student,"zhangsan");
        System.out.println(student);
    }
}
